//
//  EditScrollView.m
//  dddddemo
//
//  Created by lanou3g on 15/11/4.
//  Copyright © 2015年 zhk. All rights reserved.
//

#import "EditScrollView.h"

@implementation EditScrollView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self p_setupView];
    }
    return self;
}

- (void)p_setupView
{

    self.backgroundColor = [UIColor colorWithRed:255 / 255.0 green: 228 / 255.0 blue: 225 / 255.0 alpha:1.0];
    self.textField = [[UITextField alloc]initWithFrame:CGRectMake(20, 50, CGRectGetWidth(self.frame) - 40, 50)];
    self.textField.borderStyle = UITextBorderStyleRoundedRect;
    [self addSubview:self.textField];
    self.textView = [[UITextView alloc]initWithFrame:CGRectMake(10, CGRectGetMaxY(self.textField.frame) + 20, CGRectGetWidth(self.frame) - 20, 200)];
    self.textView.layer.cornerRadius = 10;
    self.textView.font = [UIFont systemFontOfSize:17.0];
    [self addSubview:self.textView];
    
    self.button = [UIButton buttonWithType:(UIButtonTypeSystem)];
    self.button.frame = CGRectMake(CGRectGetMaxX(self.textView.frame) * 3 / 4  + 15, CGRectGetMaxY(self.textView.frame) + 20, CGRectGetWidth(self.textView.frame) / 5, CGRectGetHeight(self.textView.frame) / 3.5);
    
    [self.button setImage:[UIImage imageNamed:@"add.png"] forState:(UIControlStateNormal)];

    [self addSubview:self.button];
    
    self.image = [[UIImageView alloc]initWithFrame:CGRectMake(CGRectGetMinX(self.textView.frame), CGRectGetMinY(self.button.frame), CGRectGetWidth(self.button.frame) + 10, CGRectGetHeight(self.button.frame) + 20)];
    
    [self addSubview:self.image];
    
    self.imageTwo = [[UIImageView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.image.frame) + 10, CGRectGetMinY(self.image.frame), CGRectGetWidth(self.image.frame), CGRectGetHeight(self.image.frame))];
    [self addSubview:self.imageTwo];
    
    self.imageThree = [[UIImageView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.imageTwo.frame) + 10, CGRectGetMinY(self.image.frame), CGRectGetWidth(self.image.frame), CGRectGetHeight(self.image.frame))];
    [self addSubview:self.imageThree];
    
    self.luyinLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMinX(self.button.frame), CGRectGetMaxY(self.button.frame), CGRectGetWidth(self.button.frame), CGRectGetHeight(self.button.frame))];
    self.luyinLabel.text = @"已有录音";
    self.luyinLabel.textColor = [UIColor darkGrayColor];
    self.luyinLabel.font = [UIFont systemFontOfSize:13.0f];
    self.luyinLabel.textAlignment = NSTextAlignmentCenter;
    self.luyinLabel.hidden = YES;
    [self addSubview:self.luyinLabel];

}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [self.textField resignFirstResponder];
    [self.textView resignFirstResponder];
}


@end
